package cn.itcast.service.cargo.impl;

import cn.itcast.dao.cargo.ShippingOrderDao;
import cn.itcast.domain.cargo.ShippingOrder;
import cn.itcast.service.cargo.ShippingOrderService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
@Service(timeout = 100000)
public class ShippingOrderServiceImpl implements ShippingOrderService {
    @Autowired
    private ShippingOrderDao shippingOrderDao;
    @Override
    public PageInfo<ShippingOrder> findByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        return new PageInfo<>(shippingOrderDao.findAll());
    }

    @Override
    public List<ShippingOrder> findAll() {
        return shippingOrderDao.findAll();
    }

    @Override
    public ShippingOrder findById(String id) {
        return shippingOrderDao.selectByPrimaryKey(id);
    }

    @Override
    public void delete(String id) {
        shippingOrderDao.deleteByPrimaryKey(id);
    }

    @Override
    public void save(ShippingOrder shippingOrder) {
        shippingOrder.setState(0);
        shippingOrderDao.insertSelective(shippingOrder);
    }

    @Override
    public void update(ShippingOrder shipping) {
        shippingOrderDao.updateByPrimaryKeySelective(shipping);
    }
}
